<template>
  <div class="main_content order-detail" v-if="detail.goods_info">
    <h2 class="main-title">订单详情</h2>
    <div class="mside order-info">
      <div class="mside__left mside__line" style="width: 290px">
        <div class="order-info__L status-1">
          <!---->
          <p class="order-no">订单号：{{ detail.order_id }}</p>
          <p class="order-status red">待付款</p>
          <div class="order-action">
            <p>
              <a
                href="javascript:void(0)"
                class="u-btn-red fill"
                @click="toPay(detail.id)"
                >立即付款</a
              >
            </p>
            <!---->
            <p>
              <a
                href="javascript:void(0)"
                class="gray"
                @click="orderCancel(detail.id)"
                >取消订单</a
              >
            </p>
            <!---->
          </div>
        </div>
      </div>
      <div class="mside__right">
        <div class="order-info__R f-kv">
          <p>
            <span class="lab">收货人：</span>
            <span class="val"
              >{{ detail.s_address.name }}，{{ detail.s_address.phone }}</span
            >
          </p>
          <p>
            <span class="lab">下单地址：</span>
            <span class="val"
              >{{ detail.s_address.area_name.split("-")[0]
              }}{{ detail.s_address.desc }}</span
            >
          </p>
          <p>
            <span class="lab">是否需要发票：</span>
            <span class="val">是</span>
          </p>
        </div>
      </div>
    </div>
    <div class="m-card">
      <div class="m-card__body">
        <div class="other-info f-kv">
          <p>
            <span class="lab">下单时间：</span>
            <span class="val">{{ detail.createdAt | timeTran }}</span>
          </p>
          <p>
            <span class="lab">配送方式：</span>
            <span class="val">快递</span>
          </p>
          <!---->
          <p>
            <span class="lab">发票类型：</span>
            <span class="val">个人-普票</span>
          </p>
          <p>
            <span class="lab">发票内容：</span>
            <span class="val">商品明细</span>
          </p>
          <p>
            <span class="lab">发票抬头：</span>
            <span class="val">客户</span>
          </p>
        </div>
      </div>
    </div>
    <div class="el-card box-card full is-never-shadow">
      <!---->
      <div class="el-card__body">
        <div class="el-row goods-info">
          <table class="order-list">
            <tbody class="order-item">
              <tr class="order-item__bd">
                <td class="goods">
                  <div
                    class="goods-item horizontal"
                    v-for="(item, index) in detail.goods_info"
                    :key="index"
                  >
                    <div class="goods-item__img">
                      <a
                        href="#"
                        target="_blank"
                        class="aspect"
                        style="width: 75px"
                        ><img :src="item.s_goods_photos[0].path"
                      /></a>
                      <!---->
                    </div>
                    <div class="goods-item__text">
                      <div class="left">
                        <div class="goods-item__title">
                          <a href="#" target="_blank">{{
                            item.desc.split("-")[0]
                          }}</a>
                        </div>
                        <div class="red">￥{{ item.sale_price }}.00</div>
                      </div>
                      <div class="right text-center">x{{ item.num }}</div>
                      <div class="col text-center">
                        <div class="goods-item__more"></div>
                      </div>
                    </div>
                  </div>
                </td>
                <td class="price">
                  ￥{{ detail.total_price }}
                  <br />
                </td>
                <td class="detail"><p class="gray">待付款</p></td>
                <td class="action">
                  <p>
                    <a
                      href="javascript:void(0)"
                      class="u-btn-red fill"
                      @click="toPay(detail.id)"
                      >立即付款</a
                    >
                  </p>
                  <!---->
                  <p>
                    <a
                      href="javascript:void(0)"
                      class="gray"
                      @click="orderCancel(detail.id)"
                      >取消订单</a
                    >
                  </p>
                  <!---->
                </td>
              </tr>
              <!---->
            </tbody>
          </table>
        </div>
      </div>
    </div>
    <div class="el-card box-card is-never-shadow">
      <!---->
      <div class="el-card__body">
        <div class="el-row fee-info">
          <div class="f-kv fr">
            <!---->
            <p>
              <span class="lab">商品总额：</span>
              <span class="val">￥{{ detail.total_price }}</span>
            </p>
            <p>
              <span class="lab">优惠金额：</span>
              <span class="val">-￥0.00</span>
            </p>
            <!---->
            <p>
              <span class="lab">运费：</span>
              <span class="val">￥0.00</span>
            </p>
            <p class="final-price">
              <span class="lab">实付款：</span>
              <span class="val red"
                ><span class="red" style="font-size: 30px"
                  >￥{{ detail.total_price }}</span
                ></span
              >
            </p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getPayDetail } from "../assets/js/request.js";
export default {
  props: ["orderCancel"],
  data() {
    return {
      detail: {},
    };
  },
  computed: {},
  filters: {
    timeTran(val) {
      let arr = val.substring(0, 19).split("T");
      let arr1 = arr[1].split(":");
      arr1[0] = +arr1[0] + 8 > 24 ? +arr1[0] + 8 - 24 : +arr1[0] + 8;
      arr[1] = arr1.join(":");
      return arr.join(" ");
    },
  },
  async created() {
    let id = this.$route.params.id;
    let res = await getPayDetail(id);
    this.detail = res;
    console.log(res);
  },
  methods: {
    //去支付
    toPay(id) {
      this.$router.push(`/pay/${id}`);
    },
  },
};
</script>

<style lang="scss">
.order-info {
  font-size: 14px;
  line-height: 1.5;
  color: #333;
  margin: 0;
  padding: 0;
  background-color: #fff;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  .mside__left {
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    margin: 0;
    padding: 0;
    float: left;
    border-right: 1px solid #f2f2f2;
    width: 290px;
    .order-info__L {
      position: relative;
      text-align: center;
      min-height: 170px;
      padding: 20px 0;
      .order-status {
        line-height: 1.5;
        text-align: center;
        margin-top: 20px;
        margin-bottom: 10px;
        font-size: 23px;
        font-weight: 700;
        color: #666;
      }
      .order-action {
        text-align: center;
        p {
          &:last-of-type {
            margin-top: 10px;
          }
          .u-btn-red {
            text-decoration: none;
            display: inline-block;
            border: 1px solid;
            line-height: normal;
            padding: 5px 15px;
            transition: 0.1s;
            cursor: pointer;
            outline: 0;
            color: #fff;
            background-color: #ee0a3b;
            border-color: #ee0a3b;
          }
          .gray {
            text-align: center;
            text-decoration: none;
            color: #777;
          }
        }
      }
    }
  }
  .mside__right {
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    margin: 0;
    padding: 0;
    overflow: hidden;
    .order-info__R {
      line-height: 2;
      padding-top: 50px;
      padding-left: 90px;
      .lab {
        display: inline-block;
        width: 110px;
      }
      .val {
        display: inline-block;
        text-align: left;
      }
    }
  }
}
.m-card {
  font-size: 14px;
  line-height: 1.5;
  color: #333;
  margin: 0;
  padding: 0;
  margin-bottom: 20px;
  background-color: #fff;
  .m-card__body {
    padding: 20px;
    .other-info {
      padding: 10px 0;
      line-height: 2;
      .lab {
        display: inline-block;
        width: 110px;
      }
      .val {
        display: inline-block;
        text-align: left;
      }
    }
  }
}
.el-card {
  margin-bottom: 20px;
  .el-card__body {
    padding: 0;
    .order-list {
      border-collapse: collapse;
      border-spacing: 0;
      width: 100%;
      line-height: 1.5;
      background-color: #fff;
      tbody {
        tr {
          width: 100%;
          font-size: 12px;
          line-height: 1.5;
          td {
            padding: 10px 0;
            &:first-of-type {
              padding-left: 20px;
            }
            &:last-of-type {
              text-align: right;
              padding-right: 20px;
            }
            .underline {
              &:hover {
                text-decoration: underline;
                cursor: pointer;
                color: #ee0a3b;
              }
            }
          }
          .goods {
            width: 550px;
            .goods-item {
              display: flex;
              align-items: center;
              .goods-item__img {
                margin-right: 20px;
              }
              & > div {
                display: flex;
                align-items: center;
              }
              .goods-item__text {
                color: #303133;
                font-size: 12px;
                text-align: left;
                margin: 0;
                padding: 0;
                overflow: hidden;
                line-height: 20px;
                height: 80px;
                vertical-align: middle;
                .left {
                  width: 200px;
                  a {
                    color: #333;
                    .good-title {
                      max-height: 40px;
                      overflow: hidden;
                    }
                  }
                  .red {
                    width: 200px;
                    color: #ee0a3b;
                  }
                }
                .right {
                  width: 100px;
                  text-align: center;
                }
              }
              img {
                width: 75px;
                height: 75px;
              }
            }
          }
          .detail {
            text-align: center;
            .gray {
              color: #aaa;
            }
          }
          .action {
            text-align: center;
            p {
              line-height: 2;
              .u-btn-red {
                color: #fff;
                background-color: #ee0a3b;
                border-color: #ee0a3b;
                display: inline-block;
                border: 1px solid;
                line-height: normal;
                padding: 5px 15px;
                transition: 0.1s;
                cursor: pointer;
                outline: 0;
              }
              .gray {
                padding: 5px 15px;
                color: #aaa;
              }
            }
          }
        }
      }
    }
    &:last-of-type {
      padding: 10px 20px;
      .el-row {
        padding: 10px 0;
        .f-kv {
          p {
            font-size: 14px;
            .lab {
              line-height: 2;
              display: inline-block;
              width: 80px;
            }
            .val {
              line-height: 2;
              display: inline-block;
              width: 160px;
              text-align: right;
            }
          }
          .final-price {
            color: #303133;
            overflow: hidden;
            margin-top: 20px;
            .red {
              color: #ee0a3b;
            }
          }
        }
      }
    }
  }
}
</style>